package com.ruoyi.apply.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.apply.domain.SysSimApply;
import com.ruoyi.apply.service.ISysSimApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * SIM申请管理Controller
 * 
 * @author laifolai
 * @date 2023-02-06
 */
@RestController
@RequestMapping("/apply/apply")
public class SysSimApplyController extends BaseController
{
    @Autowired
    private ISysSimApplyService sysSimApplyService;

    /**
     * 查询SIM申请管理列表
     */
    //@PreAuthorize("@ss.hasPermi('apply:apply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSimApply sysSimApply)
    {
        startPage();
        List<SysSimApply> list = sysSimApplyService.selectSysSimApplyList(sysSimApply);
        return getDataTable(list);
    }

    @GetMapping("/list/wait")
    public TableDataInfo listWait(SysSimApply sysSimApply)
    {
        startPage();
        sysSimApply.setStatus(0L);
        List<SysSimApply> list = sysSimApplyService.selectSysSimApplyList(sysSimApply);
        return getDataTable(list);
    }



    /**
     * 导出SIM申请管理列表
     */
    //@PreAuthorize("@ss.hasPermi('apply:apply:export')")
    @Log(title = "SIM申请管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSimApply sysSimApply)
    {
        List<SysSimApply> list = sysSimApplyService.selectSysSimApplyList(sysSimApply);
        ExcelUtil<SysSimApply> util = new ExcelUtil<SysSimApply>(SysSimApply.class);
        util.exportExcel(response, list, "SIM申请管理数据");
    }

    /**
     * 获取SIM申请管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('apply:apply:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return AjaxResult.success(sysSimApplyService.selectSysSimApplyByApplyId(applyId));
    }

    /**
     * 新增SIM申请管理
     */
    //@PreAuthorize("@ss.hasPermi('apply:apply:add')")
    @Log(title = "SIM申请管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSimApply sysSimApply)
    {
        return toAjax(sysSimApplyService.insertSysSimApply(sysSimApply));
    }

    /**
     * 修改SIM申请管理
     */
    @PreAuthorize("@ss.hasPermi('apply:apply:edit')")
    @Log(title = "SIM申请管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSimApply sysSimApply)
    {
        return toAjax(sysSimApplyService.updateSysSimApply(sysSimApply));
    }

    /**
     * 删除SIM申请管理
     */
    @PreAuthorize("@ss.hasPermi('apply:apply:remove')")
    @Log(title = "SIM申请管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(sysSimApplyService.deleteSysSimApplyByApplyIds(applyIds));
    }
}
